﻿using System;
using System.Collections.Generic;
using System.Text;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using Xeno.Core;
using OpenTK.Math;

namespace Xeno.Module
{
    public class XenoMod_Camera : XenoModule
    {
        public Matrix4 Projection { get; set; }
        public float FieldOfView { get; set; }
        public float ViewWidth { get; set; }
        public float ViewHeight { get; set; }
        public float NearZ { get; set; }
        public float FarZ { get; set; }

        public XenoMod_Camera()
        {

            ResetCamera();

        }

        public void ResetCamera()
        {

            FieldOfView = 50f;
            Projection = Matrix4.Identity;
            ViewWidth = XenoCore.DisplayWidth;
            ViewHeight = XenoCore.DisplayHeight;
            NearZ = 0.3f;
            FarZ = 1000.0f;
            InvertWorld = true;
            UpdateMatrices();

        }
        public float Deg2Rad(float ang)
        {
            return ang / 57.29578f;
        }
        public float Rad2Deg(float val)
        {
            return val * 57.29578f;
        }

        public void UpdateMatrices()
        {
            float fov = Deg2Rad(FieldOfView);
          Projection = Matrix4.Perspective(fov, ViewWidth / ViewHeight, NearZ, FarZ);

        }

    }
}
